(* /Users/admin/gmayer/work/lang/ml/stringToFile.sml
 * Write the contents of a string into a file
 *
 * Programmer: Mayer Goldberg, 2009
 

fun rel() = use "stringToFile.sml";*)

fun stringToFile (filename : string, str : string) = 
    let val f = TextIO.openOut filename
    in
        ( TextIO.output(f, str);
          TextIO.closeOut f )
    end;
    
    
(* fileToString.sml
 * Read in the contents of a file and return it as a string
 *
 * Programmer: Mayer Goldberg, 2008
 

fun rel() = use "/Users/admin/gmayer/work/lang/ml/fileToString.sml";*)

fun fileToString (filename : string) =
    let val f = TextIO.openIn filename
	fun loop s = 
	    (case TextIO.input1 f
	      of NONE => s
	       | SOME c => loop (c :: s))
	val result = String.implode (rev (loop []))
    in 
	TextIO.closeIn f;
	result
    end;
    
    
   